__author__ = 'user'
from selenium import webdriver
import pytest

from pages import YandexMainPage


@pytest.fixture(scope = 'module')
def manageDriver(request):
    driver = webdriver.Firefox()

    def quitDriver():
        driver.quit()

    request.addfinalizer(quitDriver)
    return driver

@pytest.mark.parametrize(("input", "expected"),
                         [('string to find using yandex search', 10),
                          ('euhxnsrgiiriuwdjspkhroybb9en4osmw;owiu4ondesmgow4nd7q8y5', 0)])
def test_search(manageDriver, input, expected):
    page = YandexMainPage(manageDriver)
    page.open()
    page.enterStringToSearchTextField(input)
    page.clickSearchButton()
    amountOfResultReferences = page.getAmountOfResultReferences()
    assert amountOfResultReferences == expected, \
        'Search result for string {0} isn\'t equal to expected value {1}. ' \
        'Received result is {2}'.format(input, expected, amountOfResultReferences)